<template>
  <div class="containerbox">
    <div class="container">
      <div style="margin-bottom: 20px;font-weight: bold;">店铺状态 ：{{ ['待审核','已通过','已拒绝','已冻结'][data.state] }}</div>
      <el-descriptions title="申请用户信息" border size="mini">
        <template slot="extra" v-if="data.state==1||data.state==3">
          <el-button type="primary" @click="submits" class="mr10" size="mini">{{ data.state==1?'冻结':'解冻' }}</el-button>
        </template>
        <template slot="extra" v-if="data.state==0">
          <el-button type="primary" @click="submit" class="mr10" size="mini">通过</el-button>
          <el-button type="primary" @click="submi" class="mr10" size="mini">拒绝</el-button>
        </template>
        <el-descriptions-item label="申请用户昵称">{{ data.user.nickname }}</el-descriptions-item>
        <el-descriptions-item label="申请用户电话">{{ data.user.mobile}}</el-descriptions-item>
        <el-descriptions-item label="姓名">{{ data.username }}</el-descriptions-item>
        <el-descriptions-item label="身份证">{{ data.card}}</el-descriptions-item>
        <el-descriptions-item label="身份证正面">
          <el-image class="table-td-thumb"  style="height: 60px;width: 60px;" :src="data.positive" :preview-src-list="[data.positive]"></el-image>
        </el-descriptions-item>
        <el-descriptions-item label="身份证反面">
          <el-image class="table-td-thumb" style="height: 60px;width: 60px;" :src="data.side" :preview-src-list="[data.side]"></el-image>
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="店铺信息" border  size="mini" style="margin-top: 20px;">
        <el-descriptions-item label="店铺名称">{{ data.name }}</el-descriptions-item>
        <el-descriptions-item label="联系电话">{{ data.mobile}}</el-descriptions-item>
        <el-descriptions-item label="店铺地址">{{ data.province+data.city+data.area+data.address }}</el-descriptions-item>
        <el-descriptions-item label="申请类型">{{ data.types==0?'个人':'企业'}}</el-descriptions-item>
        <el-descriptions-item label="商家类型">{{ data.code==0?'线上商家':'线下商家' }}</el-descriptions-item>
        <el-descriptions-item label="店铺类型">{{ data.shop_class.name }}</el-descriptions-item>
        <el-descriptions-item label="店铺介绍">{{ data.introduce }}</el-descriptions-item>
        <el-descriptions-item label="经营范围">{{ data.trade }}</el-descriptions-item>

        <el-descriptions-item label="企业名称" v-if="data.types==1">{{ data.enterprise }}</el-descriptions-item>
        <el-descriptions-item label="营业执照号码" v-if="data.types==1">{{ data.trade_code }}</el-descriptions-item>

        <el-descriptions-item label="店铺LOGO">
          <el-image class="table-td-thumb" style="height: 60px;width: 60px;" :src="data.shop_head" :preview-src-list="[data.shop_head]"></el-image>
        </el-descriptions-item>
        <el-descriptions-item label="营业执照">
          <el-image class="table-td-thumb" style="height: 60px;width: 60px;" :src="data.license" :preview-src-list="[data.license]"></el-image>
        </el-descriptions-item>
        <el-descriptions-item label="补充材料">
          <el-image v-if="data.other" class="table-td-thumb" style="height: 60px;width: 60px;" :src="data.other" :preview-src-list="[data.other]"></el-image>
        </el-descriptions-item>

      </el-descriptions>
      <!-- <div v-if="data.state==0">
        <el-button type="primary" @click="submit" class="mr10" size="small">通过</el-button>
        <el-button type="primary" @click="submi" class="mr10" size="small">拒绝</el-button>
      </div>
      <div v-if="data.state==1||data.state==3">
        <el-button type="primary" @click="submits" class="mr10" size="small">{{ data.state==1?'冻结':'解冻' }}</el-button>
      </div> -->

    </div>
  </div>
</template>


<script>
export default {
  data() {
    return {
      form: {},
      order_logistics: '',
      order_waybill: '',
      shopping_list:[],
      id: 0,
      data:{},
      list: ["顺丰", '邮政', '中通', '圆通', '申通', '京东', '百世快递', '韵达', '德邦', '天天', '其他']
    };
  },
  created() {
    // this.data = JSON.parse(this.$route.query.data)
    // console.log(this.data)
    // this.getdata(this.id)
  },
  mounted(){
     this.data = JSON.parse(this.$route.query.data)
     console.log(this.data)
  },
  watch: {
    '$route': { // $route可以用引号，也可以不用引号  监听的对象
      handler(to, from){
       this.data = JSON.parse(this.$route.query.data)
      },
      deep: true, // 深度观察监听 设置为 true
      immediate: true, // 第一次初始化渲染就可以监听到
      }
    },
  methods: {

    getdata(id) {
      this.request('admin/order/', 'put', { order: id }).then(res => {
        console.log(res)
        this.form = res.data[0]
        this.form['address']=res.data[0].province+res.data[0].city+res.data[0].area+res.data[0].detailed
        this.shopping_list=res.data
      })
    },
    submi() {
      let that = this
      this.$prompt('请输入拒绝原因', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({ value }) => {
        that.request('admin/businessList/', 'post', { 'id': that.data.ID, 'code': 1, reason: value }).then(res => {
          if (res.errno == 0) {
            that.$message.success(res.errmsg);
            // setTimeout(function () {
            //   that.$router.push({ path: '/Entrepreneurship/unit' })
            // }, 500);
             setTimeout(function () {
              that.$router.push({ path: '/business/merchantManagement'})
              //this.$router.go(-1); // 返回上一页
              }, 500);
          } else {
            that.$message.error(res.errmsg)
          }
        })
      }).catch(() => {

      });

    },
    submit() {
      let that=this
      this.request('admin/businessList/', 'post', {'id': this.data.ID,'code':0}).then(res => {
        if (res.errno == 0) {
          this.$message.success(res.errmsg);
          setTimeout(function () {
            that.$router.push({ path: '/business/merchantManagement'})
            //this.$router.go(-1); // 返回上一页
            }, 500);
        } else {
          this.$message.error(res.errmsg)
        }
      })
    },
    submits(){
      let that=this
      this.request('admin/businessList/', 'PUT', {'id': this.data.ID}).then(res => {
        if (res.errno == 0) {
          this.$message.success(res.errmsg);
          setTimeout(function () {
            //that.$router.push({ path: '/Entrepreneurship/unit'})
            //this.$router.go(-1); // 返回上一页
             that.$router.push({ path: '/business/merchantManagement'})
            }, 500);
        } else {
          this.$message.error(res.errmsg)
        }
      })
    }

  },

}
</script>

<style scoped="scoped">
.containerbox {
  padding: 20px;
}

.goodslist {
  height: 200px;
  /* background-color: snow; */
  display: flex;
  justify-content: flex-start;
  /* align-items: center; */
  width: 100%;

}

.goodslist img {
  width: 100px;
  height: 100px;
  margin-right: 20px;
}
.goodsdetail div{
margin: 10px 0;
}
.submt {

  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
}
</style>
